<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Grom Hellscream
 * Date: 10/29/12
 * Time: 2:38 PM
 * To change this template use File | Settings | File Templates.
 */
// No direct access to this file
defined('_JEXEC') or die;

// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');

/**
 * Vien Form Field class for the Vast component
 */
class JFormFieldVien extends JFormFieldList
{
    /**
     * The field type.
     *
     * @var         string
     */
    protected $type = 'vien';

    /**
     * Method to get a list of options for a list input.
     *
     * @return      array           An array of JHtml options.
     */
    protected function getOptions()
    {
        $db = JFactory::getDBO();
        $query = $db->getQuery(true);
        $query->select('*');
        $query->from('#__vien');
        $db->setQuery((string)$query);
        $viens = $db->loadObjectList();
        $options = array();
        if ($viens)
        {
            foreach($viens as $vien)
            {
                $options[] = JHtml::_('select.option', $vien->id, $vien->hinhanh, $vien->gioithieu, $vien->cosovatchat, $vien->chucnang, $vien->hoatdong, $vien->cocautochuc, $vien->nhanluckhoahoc);
            }
        }
        $options = array_merge(parent::getOptions(), $options);
        return $options;
    }
}